<template>
  <div>
    <el-form
      ref="form"
      size="small"
      :model="form"
      label-position="top"
      label-width="100px"
      :rules="rules"
    >
      <el-row :gutter="20" class="disWrap">
        <el-col :span="12">
          <el-form-item label="名称：" prop="name">
            <el-input v-model="form.name"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="序号：" prop="indexNum">
            <el-input-number
              v-model="form.indexNum"
              controls-position="right"
              :min="1"
            ></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="标题：" prop="contentLists[0].title">
            <el-input v-model="form.contentLists[0].title"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" style="margin-top: 36px">
          <slot></slot>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    index: {
      type: Number,
      default: 1
    },
    list: {
      type: Object,
      default: () => {
        return { contentLists: [{}] }
      }
    }
  },
  watch: {
    form: {
      handler: function (n, o) {
        this.$emit('onChange', n)
      },
      immediate: true,
      deep: true
    }
  },
  mounted() {},
  data() {
    return {
      form: {
        indexNum: this.index,
        ...this.list
      },
      rules: {
        name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
        indexNum: [{ required: true, message: '请输入序号', trigger: 'blur' }],
        'contentLists[0].title': [
          {
            required: true,
            message: '请输入标题',
            trigger: 'blur'
          }
        ]
      }
    }
  }
}
</script>

<style></style>
